package com.linux.huhx.thread3;

import java.util.concurrent.TimeUnit;

public class SynchronizedTest {
    public static void main(String[] args) {
        MyThreadA threadA = new MyThreadA();
        new Thread(threadA, "T-1").start();
        new Thread(threadA, "T-2").start();
    }

    static class MyThreadA implements Runnable {
        @Override
        public void run() {
            System.out.println(Thread.currentThread().getName() + " outside of synchronized.");
//            synchronized (this) {
                for (int i = 0; i < 3; i++) {
                    try {
                        TimeUnit.SECONDS.sleep(i + 1);
                        System.out.println(Thread.currentThread().getName() + " , i = " + i);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
//            }
        }
    }
}
